﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/static/include/top.jsp"%>

<c:set var="shyj" value="<%=ReportConstant.PROVINCE_AREA_ID%>"></c:set>

<script>document.title="企业列表";</script>
<script type="text/javascript">
function openEditWin(id){
	openWin("修改详情","${baseURL}/unit/edit?id="+id,800,500,xxx);
}
function openViewWin(id){
	openWin("查看详情","${baseURL}/unit/view?id="+id,800,500);
}
function xxx(){
	searchForm.submit();
	return false;
}
</script>

<table>
	<tbody>

		<tr>
			<th><img src="${ctx}/static/images/pages/cen/rig/ico_01.png"
				align="absmiddle">&nbsp;企业名录管理</th>
		</tr>
		<tr class="tab_grey">
			<td>
				<form name="searchForm" action="" method="post">
					<input type="hidden" name="p" value="1" /> 录入年份： <select
						id="createYear" name="createYear" class="tab_textbut">
						<option value="">请选择..</option>
						<c:forEach var="year" items="${yearList}">
							<option value="${year}">${year}</option>
						</c:forEach>
					</select> <span class="tab_text"> 单位名称： </span> <input id="unitName"
						type="text" name="unitName" value="${param['unitName']}" size="20"
						class="tab_textbut" /> <span class="tab_text">企业编号：</span> <input
						id="unitNo" type="text" name="unitNo" value="${param['unitNo']}"
						size="20" class="tab_textbut" /> <span class="tab_text">单位类型：</span>
					<select id="roleId" name="roleId" class="tab_textbut">
						<option value="">请选择..</option>
						<c:forEach var="role" items="${roleList}">
							<option value="${role.id}">${role.roleName}</option>
						</c:forEach>
					</select> 
					<a class="tab_but" href="#"
						onclick="searchForm.action='${baseURL}/unit/list';searchForm.submit();return false;">查询</a>
					<a class="tab_but" href="#" onclick="clearInput();return false;">清空</a><br/>
				</form>
				<form name="uploadForm" target="upload"
					action="${baseURL}/unit/import" method="post"
					enctype="multipart/form-data">
					<a class="tab_but02" href="${baseURL}/role/downloadUnitTemple"	onclick="${baseURL}/role/downloadUnitTemple">下载单位模板</a>
					<input type="file" name="uploadFile" id="uploadFile"> <a
						class="tab_but02" href="#"
						onclick="impUnitInfo();return false;">单位信息导入</a>${msg }
						<a class="tab_but02" href="#" onclick="searchForm.action='${baseURL}/unit/downloadInfo';searchForm.submit();">导出单位信息</a>
				
				</form>
				<c:if test="${sessionScope.user.userAreaId eq shyj}">
				<form name="uploadInfoForm" target="upload"
					action="${baseURL}/unit/uploadInfo" method="post"
					enctype="multipart/form-data">
					报表制度 <select id="typeId" name="typeId" class="tab_textbut">
						<c:forEach var="sys" items="${sysList}">
							<c:if test="${sys.code eq '4'}">
								<option value="${sys.code}">${sys.codeName}</option>
							</c:if>
						</c:forEach>
					</select> <span class="tab_text">年份:</span>
						<select id="year" name="year" onchange="getRep();" class="tab_textbut">
						<option value="">请选择..</option>
						<c:forEach var="year" items="${yearList}">
							<option value="${year}">${year}</option>
						</c:forEach>
					</select> <span class="tab_text">报表</span>
					<select id="reportTypeId" name="reportTypeId" class="tab_textbut_300">
					</select> 
					<span class="tab_text"></span>
					<input type="file" name="uploadInfo" id="uploadInfo"> <a
						class="tab_but02" href="#"
						onclick="importCompany();return false;">导入用海项目信息</a>${msg }
				</form>
				</c:if>
				<script>
		$("#roleId").val("${param['roleId']}");
		$("#createYear").val("${param['createYear']}");
		$("#unitName").val("${param['unitName']}");
		$("#unitNo").val("${param['unitNo']}");
		$("#year").val("${param['year']}");
		
		
		function clearInput() {
			$("#roleId").val("");
			$("#createYear").val("");
			$("#unitName").val("");
			$("#unitNo").val("");
		}
		</script> <iframe name="upload" width="0" height="0" frameborder="0"></iframe>
			</td>
		</tr>

	</tbody>
</table>



<br />
<c:if test="${empty obj.operationResult}">
	<b>没有符合条件的记录。</b>
</c:if>
<c:if test="${not empty obj.operationResult}">

	<table id="listTable">
	<tbody>
		<tr>
		<th width="3%"><input type="checkbox" onclick="selectAll(this.checked);"></th>
				<th width="8%">录入年份</th>
				<th width="20%">企业名称</th>
				<th width="10%">企业编号</th>
				<th width="10%">行政区划</th>
				<th width="10%">单位类型</th>
				<th width="8%">单位法人</th>
				<th width="10%">联系电话</th>
				<th>操作</th>
				
			
		</tr>
		<c:forEach var="oneRow" items="${obj.operationResult}">

			<tr>
				<td><input name="chk"
					type="checkbox" id="chk" value="${oneRow.id}" /></td>
				<td align="left" >${oneRow.createYear}</td>
				<td align="left" class="tab_td_rig">${oneRow.unitName}</td>
				<td align="left" >${oneRow.superCompanyCode}</td>
				<td align="left" >${oneRow.areaName}</td>
				<td align="left" >${oneRow.roleName}</td>
				<td align="left" >${oneRow.fr}</td>
				<td align="left" >${oneRow.tel}</td>
				<td align="left" ><a href="#"
					onclick="openEditWin('${oneRow.id}')"><img
						src="${baseURL}/static/images/tab/ico_01.png" width="16"
						height="16" border="0" align="absmiddle" />修改</a> <a href="#"
					onclick="openViewWin('${oneRow.id}')"><img
						src="${baseURL}/static/images/tab/ico_01.png" width="16"
						height="16" border="0" align="absmiddle" />查看</a>
					<a href="#" onclick="uploadPic('${oneRow.id}')"><img src="${baseURL}/static/images/tab/ico_01.png" width="16"
						height="16" border="0" align="absmiddle" />企业图片管理</a>					
				</td>
			</tr>
		</c:forEach>
		<tr class="tab_grey">
				<td colspan="9" align="center" valign="middle" class="tab_white">
				<div class="pagination"> 
					<%@ include file="../include/listpage2.jsp"%>
				</div>
				<div class="clear"></div>
				</td>
			</tr>	
		
		</tbody>
	</table>
	<script>

function selectAll(checkAllFlag) {
	var checkArray = document.getElementsByName("chk");
	for (var i = 0; i < checkArray.length; i++) {
		checkArray[i].checked = checkAllFlag;
	}
}

function getRep() {
	var ptype = $('#typeId').val();
	var pyear= $('#year').val();
	
	$.ajax({
		url: '${baseURL}/unit/getReps',
		type: 'post',
		data: 'year=' + pyear + '&typeId=' + ptype,
		dataType: 'json',
		success: function(data){
			$("#reportTypeId").empty();
			$("#reportTypeId").append( "<option value='0'>请选择..</option>" );
			$.each(data, function(i, item) {
	            $("#reportTypeId").append( "<option value='" + item.id + "'>" + item.typeName + "</option>" );
	       	});
		}		
	});
}

$(document).ready(function (){
	
	$("#typeId").bind("change", function(){
		$("#reportTypeId").val("");
		$("#year").val("");
	});
	
});

function importCompany(){

	if ($("#reportTypeId :selected").text().indexOf("2表") == -1){
		layer.alert("请选择海域使用权证报表！");
		return ;
	}
	
	if ($("#uploadInfo").val()==""){
		layer.alert("请选择导入的文件！");
		return ;
	}
	
	uploadInfoForm.submit();
}
function impUnitInfo(){
	
	if ($("#uploadFile").val()==""){
		layer.alert("请选择导入的模板文件。");
		return ;		
	}
	
	uploadForm.submit();
	
	
}
//企业图片管理
function uploadPic(unitId){
	openWin("企业图片管理", "${baseURL}/unit/unitPicMgr/" + unitId, 800, 550);
}
</script>
</c:if>

<%@ include file="/static/include/bottom.jsp"%>
